

package com.loong.loong.hik.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.loong.loong.common.core.util.R;
import com.loong.loong.common.log.annotation.SysLog;
import com.loong.loong.hik.entity.HikCdcProgram;
import com.loong.loong.hik.service.HikCdcProgramService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.loong.loong.common.excel.annotation.ResponseExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 疾控中心节目
 *
 * @author jinyiang
 * @date 2023-04-24 10:08:15
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/hikcdcprogram" )
@Api(value = "hikcdcprogram", tags = "疾控中心节目管理")
public class HikCdcProgramController {

    private final  HikCdcProgramService hikCdcProgramService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param hikCdcProgram 疾控中心节目
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcprogram_view')" )
    public R getHikCdcProgramPage(Page page, HikCdcProgram hikCdcProgram) {
        return R.ok(hikCdcProgramService.page(page, Wrappers.query(hikCdcProgram)));
    }


    /**
     * 通过id查询疾控中心节目
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcprogram_view')" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(hikCdcProgramService.getById(id));
    }

    /**
     * 新增疾控中心节目
     * @param hikCdcProgram 疾控中心节目
     * @return R
     */
    @ApiOperation(value = "新增疾控中心节目", notes = "新增疾控中心节目")
    @SysLog("新增疾控中心节目" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('hik_hikcdcprogram_add')" )
    public R save(@RequestBody HikCdcProgram hikCdcProgram) {
        return R.ok(hikCdcProgramService.save(hikCdcProgram));
    }

    /**
     * 修改疾控中心节目
     * @param hikCdcProgram 疾控中心节目
     * @return R
     */
    @ApiOperation(value = "修改疾控中心节目", notes = "修改疾控中心节目")
    @SysLog("修改疾控中心节目" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('hik_hikcdcprogram_edit')" )
    public R updateById(@RequestBody HikCdcProgram hikCdcProgram) {
        return R.ok(hikCdcProgramService.updateById(hikCdcProgram));
    }

    /**
     * 通过id删除疾控中心节目
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除疾控中心节目", notes = "通过id删除疾控中心节目")
    @SysLog("通过id删除疾控中心节目" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('hik_hikcdcprogram_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(hikCdcProgramService.removeById(id));
    }


    /**
     * 导出excel 表格
     * @param hikCdcProgram 查询条件
     * @return excel 文件流
     */
    @ResponseExcel
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('hik_hikcdcprogram_export')" )
    public List<HikCdcProgram> export(HikCdcProgram hikCdcProgram) {
        return hikCdcProgramService.list(Wrappers.query(hikCdcProgram));
    }
}
